<?php
	// 接收前端参数把数据插入数据库
	
$name=$_GET['name'];
$price=$_GET['price'];
$num=$_GET['num'];
// 链接数据库
$conn=mysqli_connect('localhost','root','root','main');
mysqli_query($conn,"set charset 'utf8'");
mysqli_query($conn,"set character set 'utf8'");
$sql = "insert into shop (name,price,num) values ('$name',$price,$num)";
// 得到查询结果
$res=mysqli_query($conn,$sql);
if($res){
	echo json_encode(array(
	"code"=>200,
	"body"=>array(
	"msg"=>"添加成功"
		)
	));
}else{
	echo json_encode(array(
	"code"=>201,
	"body"=>array(
	"msg"=>"添加失败"
		)
	));
}


?>